<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class CommentModel extends Model
{

	
	/**
     * 通过审核
     *
     * @access public
     * @param $cmtID array
     * @return null
    */
	public function approveCommentByID($cmtID)
	{
	    $where = array('comment_id' => array('in', $cmtID));
		$this->where($where)->setField('is_visible', 1);
	}


	/**
     * 否决审核
     *
     * @access public
     * @param $cmtID array
     * @return null
    */
	public function disapproveCommentByID($cmtID)
	{
	    $where = array('comment_id' => array('in', $cmtID));
		$this->where($where)->setField('is_visible', -1);
	}


	/**
     * 还原评论
     *
     * @access public
     * @param $cmtID array
     * @return null
    */
	public function restoreCommentByID($cmtID)
	{
	    $where = array('comment_id' => array('in', $cmtID));
		$this->where($where)->setField('is_visible', 1);
	}


	/**
     * 删除评论
     *
     * @access public
     * @param $cmtID array
     * @return null
    */
	public function deleteCommentByID($cmtID, $direct=0)
	{
		$recycle = get_site_config('recycle_bin_enable');
		$where = array('comment_id' => array('in', $cmtID));
		if ($direct || !$recycle)
		{
			$this->where($where)->delete();
		}
		else
		{
			$this->where($where)->setField('is_visible', -1);
		}
	}


	/**
	 * 删除用户的评论
	 *
	 * @param array $userID
	 * @param integer $direct
	 */
	public function deleteCommentByUserID($userID, $direct=0)
	{
		$recycle = get_site_config('recycle_bin_enable');
		$where['poster_id'] = array('in', $userID);
		if ($direct || !$recycle)
		{
			$this->where($where)->delete();
		}
		else
		{
		    $this->where($where)->setField('is_visible', -1);
		}
	}

}


/* End of file CommentModel.class.php */
/* Location: ./App/Lib/Model/CommentModel.class.php */